﻿using System.Text;

namespace msilgc.cbuilder.CSyntaxTree
{
    internal class ReturnStatement : ICStatement {
        public IVariable ReturnValueIfPresent { get; set; }

        public ReturnStatement() {
            ReturnValueIfPresent = null;
        }

        public ReturnStatement(IVariable returnValue) {
            ReturnValueIfPresent = returnValue;
        }

        public void Emit(StringBuilder builder) {
            builder.Append("return");
            if(ReturnValueIfPresent != null)
            {
                builder.Append(" ");
                ReturnValueIfPresent.Emit(builder);
            }
            builder.AppendLine(";");
        }
    }
}